package controller;

import java.io.IOException;
import java.sql.ResultSet;

import javax.ejb.EJB;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.HttpConstraint;
import javax.servlet.annotation.ServletSecurity;
import javax.servlet.annotation.ServletSecurity.TransportGuarantee;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class FilmQuery
 */
@ServletSecurity(
@HttpConstraint(transportGuarantee = 
TransportGuarantee.CONFIDENTIAL,
rolesAllowed = {"admini","goscie"}))

@WebServlet("/FilmQuery")
public class FilmQuery extends HttpServlet {
	private static final long serialVersionUID = 1L;
    
    /**
     * @see HttpServlet#HttpServlet()
     */
    public FilmQuery() {
       
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		OracleProcedure op = new OracleProcedure(OracleProcedure.SELECT,"Film");
		op.make(true);
		ResultSet cursor = op.getCursor();
		request.setAttribute("filmList", Utils.prepareFilmList(cursor)); 

		RequestDispatcher dispatcher = 
	    		getServletContext().getRequestDispatcher("/guest/index.jsp"); 
	    dispatcher.forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
	}
}
